{include file="public/header"}
    <style type="text/css">
    	#wrapper {
            width: 100%;
            position: absolute;
            left: 0;
            top:90px;
            overflow: hidden;
            z-index: 1;
            /* 防止本机Windows上的触摸事件 */
            -ms-touch-action: none;
            /* 防止callout tap-hold和文本的选择 */
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            /* 防止文本调整取向变化对web应用程序很有用 */
            -webkit-text-size-adjust: none;
            -moz-text-size-adjust: none;
            -ms-text-size-adjust: none;
            -o-text-size-adjust: none;
            text-size-adjust: none;
			height: 300px;
        }
        .pull-loading {
            text-align: center;
            height: 40px;
            line-height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
			color: #fff;
        }
        #scroller ul li {}
        .container{padding:0}
    </style>
    <script type="text/javascript">
    function countDown(obj,endTime){
        var time_start = new Date().getTime(); //设定当前时间
        var time_end =  parseInt(endTime); //设定目标时间
        // 计算时间差
        var time_distance = time_end - time_start;
		if(time_distance < 0){  // 日期已过
			console.log(obj);
			$(obj).text("已到期");//加载数据后，发现已经过期了，没有倒计时的必要
			return false;
		}
        // 天
        var int_day = Math.floor(time_distance/86400000);
        time_distance -= int_day * 86400000;
        // 时
        var int_hour = Math.floor(time_distance/3600000);
        time_distance -= int_hour * 3600000;
        // 分
        var int_minute = Math.floor(time_distance/60000);
        time_distance -= int_minute * 60000;
        // 秒
        var int_second = Math.floor(time_distance/1000);
        // 时分秒为单数时、前面加零
        if(int_day < 10 && int_day > 0){
            int_day = "0" + int_day;
        }
        if(int_hour < 10){
            int_hour = "0" + int_hour;
        }
        if(int_minute < 10){
            int_minute = "0" + int_minute;
        }
        if(int_second < 10){
            int_second = "0" + int_second;
        }
        if(int_day<=0 && int_hour<=0 && int_minute <=0 && int_second<=0){
            console.log(obj);
            $(obj).text("已到期");//加载数据后，发现已经过期了，没有倒计时的必要
            return false;
        }
        // 显示时间
        if(int_day>0){
            var result = parseInt(int_day)+"天"+int_hour+"小时"+int_minute+"分"+int_second+'秒';
		}else{
            var result = int_hour+"小时"+int_minute+"分"+int_second+'秒';
		}
        $(obj).text(result);
        // 设置定时器
        setTimeout("countDown("+"'"+obj+"'"+","+endTime+")",1000);
    }
    </script>
<body class="she_body">
<div class="bg_fixed_v10_1"></div>
	<div class="sectionY sectionY_tttt">
        <a href="{:url('User/index')}">
			<img src="__PUBLIC__/home/images/v10_a9.png" alt="" class="a1">
		</a>
		<p class="p1">
			<span class="ppp_title">抢购记录</span>
		</p>
	</div>
	<div class="kong1"></div>
	<div class="zu_section1 clearfix">
		<div class="zu_section1_1 clearfix">
			<ul class="zu_li">
				<li {if condition="$types eq 1"} class='select' {/if} >
				<a href="{:url('Rent/index',['types'=>1])}">抢购中</a>
				</li>
				<li {if condition="$types eq 2"} class='select' {/if}>
				<a href="{:url('Rent/index',['types'=>2])}" >已抢购</a>
				</li>
				<li {if condition="$types eq 3"} class='select' {/if} >
				<a href="{:url('Rent/index',['types'=>3])}" >取消/申诉</a>
				</li>
			</ul>
		</div>
	</div>
<style>
	.trtr{
		padding: 10px;
	}
	.trtr .k1{
		background: url("__PUBLIC__/home/images/v10_a42.png");
		background-size: 100% 100%;
		padding: 20px 15px;
	}
</style>
	<div class="zu_section2">
		   <div class="container" id='wrapper'>
                <div id="scroller" >
                    <div class="trtr">
                        {volist name='list' id='v'}
                                <div class="k1">
                					<div class="f1 clearfix">
                						<span class="s1">订单编号：{$v.ctime}-{$v.id}</span>

                					</div>
                					<div class="f2">
                						<p class="p1">
                							<span class="s1">类型：</span>
                							<span class="s2 sred">{$v.title}</span>
                						</p>
                						<p class="p1">
                							<span class="s1">应付费用：</span>
                							<span class="s2 sred">{$v.basicprice}</span>
                						</p>
                						<p class="p1">
                							<span class="s1">合约收益：</span>
                							<span class="s2 sbla">{$v.daynum|default=0}天/{$v.earnpercent|default=0}%</span>
                						</p>
                						<p class="p1">
                							<span class="s1">抢购时间：</span>
                							<span class="s2">{$v.peiduitime|date='Y-m-d H:i:s',###}</span>
                						</p>
                                        {if condition="$v['paystatus'] eq 0"}
                                            <p class="p1">
                    							<span class="s1">付款剩余时间：</span>
                    							<span class="s2 sred" id='oneTime{$v.id}'></span>
                                                <?php $peiduitime = ($v['peiduitime']+config('setting.pay_limit_time')*60); ?>
                                                <script>countDown('#oneTime'+{$v.id},parseInt({$peiduitime}*1000));</script>
                    						</p>
                                        {/if}
                                        {if condition="$v['paystatus'] gt 0"}
                                            <?php if($v['paystatus']!=2){ ?>
                                            <p class="p1">
                    							<span class="s1">确认收款剩余时间：</span>
                    							<span class="s2 sred" id='oneTime{$v.id}'></span>
                                                <?php $recive_time = ($v['paytime']+config('setting.pay_limit_time')*60); ?>
                                                <script>countDown('#oneTime'+{$v.id},parseInt({$recive_time}*1000));</script>
                    						</p>
                                        <?php } ?>
                                        {/if}
                                        <p class="p1">
                							<span class="s1">订单状态：</span>
                                            {if condition="$v['paystatus'] lt 2"}
                                                <span class="s2 sorg">抢购中</span>
                                            {/if}
                                            {if condition="$v['paystatus'] eq 2"}
                                                <span class="s2 sorg">已抢购</span>
                                            {/if}
                						</p>
                					</div>
                					<div class="f3 clearfix">
                						<a href="{:url('Rent/payrentok',['id'=>$v['id']])}" class="a1">订单详情</a>
                                        {if condition="$v['paystatus'] eq 0"}
                                            <?php if(time()>$peiduitime){ ?>
                                                    <a class="a2">已过期，无法支付</a>
                                            <?php }else{ ?>
                						    <a href="{:url('Rent/payrent',['id'=>$v['id']])}" class="a2">付款</a>
                                        <?php } ?>
                                        {/if}
                                        {if condition="$v['paystatus'] eq 1"}
                						    <a class="a2">等待确认</a>
                                        {/if}
                                        {if condition="$v['paystatus'] eq 2"}
                						    <a class="a2">已抢购</a>
                                        {/if}
                					</div>
                            	</div>
                        {/volist}

                    </div>
                    <div class="pull-loading">上拉加载</div>
                </div>

		   </div>

	</div>
</body>
</html>
<script type="text/javascript">
    $(function(){
        var dd = $("#wrapper").offset().top;
        $("#wrapper").css("height",($(window).height()-dd-80));
        $("#wrapper").css("top",dd+10);
    })
</script>

<script type="text/javascript">


$(function(){
    var d = $(window).height()-46-44;
    // $(".zu_section2").css("height",d);

})
    var myscroll = new iScroll("wrapper", {
        onScrollMove: function () { //拉动时
            //上拉加载
            if (this.y < this.maxScrollY) {
                $(".pull-loading").html("释放加载");
                $(".pull-loading").addClass("loading");
            } else {
                $(".pull-loading").html("上拉加载");
                $(".pull-loading").removeClass("loading");
            }
        },
        onScrollEnd: function () { //拉动结束时
            //上拉加载
            if ($(".pull-loading").hasClass('loading')) {
                $(".pull-loading").html("加载中...");
                pullOnLoad();
            }
        }
    });
    //上拉加载函数,ajax
    var num = 1;
    function pullOnLoad() {
        num++;
        $.ajax({
            type:'post',
            url:"{:url('Rent/ajaxmorerentindex')}?types={$types}",
            data:{page:num},
            cache:false,
            dataType:'JSON',
            success:function(data){
                if(data.length<=0){
                    $('.pull-loading').html("已加载全部");
                }else{
                    var html = '';
                    for(var i=0;i<data.length;i++){
                        html += '<div class="k1">';
                        html += '   <div class="f1">';
                        html += '   <img src="__PUBLIC__/home/images/a58.png" alt="" class="im1">';
                        html += '   <span class="s1">订单编号：'+data[i]['ctime2']+'-'+data[i]['id']+'</span>';
                        html += '</div><div class="f2"><p class="p1"><span class="s1">类型：</span>';
                        html += '<span class="s2 sred">'+data[i]['title']+'</span>';
                        html += '</p><p class="p1"><span class="s1">应付费用：</span>';
                        html += '<span class="s2 sred">'+data[i]['basicprice']+'</span>';
                        html += '<p class="p1"><span class="s1">合约收益：</span>';
                        html += '<span class="s2 sbla">'+data[i]['daynum']+'天/'+data[i]['earnpercent']+'%</span></p>';
                        html += '</p><p class="p1"><span class="s1">抢购时间：</span>';
                        html += '<span class="s2">'+data[i]['peiduitime2']+'</span></p>';
                        if(data[i]['paystatus']==0){
                            html += '<p class="p1">';
                            html += '<span class="s1">付款剩余时间：</span>';
                            html += '<span class="s2 sred" id="oneTime'+data[i]['id']+'"></span>';
                            //html += countDown("#oneTime"+data[i]['id'],parseInt(data[i]['peiduitime3']*1000));
                            html += '<p class="p1">';
                            html += '<p class="p1">';
                        }
                        if(data[i]['paystatus']>0){
                            html += '<p class="p1">';
                            html += '<span class="s1">确认收款剩余时间：</span>';
                            html += '<span class="s2 sred" id="oneTime'+data[i]['id']+'"></span>';
                            //html += countDown("#oneTime"+data[i]['id'],parseInt(data[i]['recive_time']*1000));
                            html += '<p class="p1">';
                            html += '<p class="p1">';
                        }
                        html += '<p class="p1">';
                        html += '<span class="s1">订单状态：</span>';
                        if(data[i]['paystatus']<2){
                            html += '<span class="s2 sorg">抢购中</span>';
                        }
                        if(data[i]['paystatus']==2){
                            html += '<span class="s2 sorg">已抢购</span>';
                        }
                        html += '</p></div>';
                        html += '<div class="f3 clearfix">';
                        var url = "{:url('Rent/payrentok')}?id="+data[i]['id'];
                        html += '<a href="'+url+'" class="a1">订单详情</a>';
                        html += '';

                        if(data[i]['paystatus']==0){
                            if(data[i]['timestamps']>data[i]['peiduitime3']){
                                html += '<a class="a2">已过期，无法支付</a>';
                            }else{
                                var url_pay = "{:url('Rent/payrent')}?id="+data[i]['id'];
                                html += '<a href="'+url_pay+'" class="a2">付款</a>';
                            }
                        }
                        if(data[i]['paystatus']==1){
                            html +='<a class="a2">等待确认</a>';
                        }
                        if(data[i]['paystatus']==2){
                            html +='<a class="a2">已抢购</a>';
                        }

                        html += ' </div>';
                        html += '  </div>';
                    }

                    /*循环执行这个js*/
                    for(var i=0;i<data.length;i++){
                        if(data[i]['paystatus']==0){
                            countDown("#oneTime"+data[i]['id'],parseInt(data[i]['peiduitime3']*1000));
                        }
                        if(data[i]['paystatus']>0){
                            countDown("#oneTime"+data[i]['id'],parseInt(data[i]['recive_time']*1000));
                        }
                    }
                    $("#scroller .trtr").append(html);
                    $('.pull-loading').html("上拉加载");
                }
				myscroll.refresh();
            }
        });
    }
    // pullOnLoad();
</script>
